<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>{:session('cp.cpsysname')}--商户管理平台</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
    <meta name="description" content="{:config('webconfig.description');}">
    <meta name="keywords" content="{:config('webconfig.keywords');}">
    <meta name="author" content="runoob">
    <link rel="stylesheet" href="__STATIC_URL__/static/bootstrap/3.3.7/css/bootstrap.min.css">
    <link rel="stylesheet" type="text/css" href="__STATIC_URL__/static/css/bootstrap-datetimepicker.css"/>
    <link rel="stylesheet" type="text/css" href="__STATIC_URL__/static/css/index.css"/>
    <script src="__STATIC_URL__/static/js/jquery.min.js"></script>
    <script src="__STATIC_URL__/static/bootstrap/3.3.7/js/bootstrap.min.js"></script>
    <script src="__STATIC_URL__/static/js/bootstrap-datetimepicker.js" type="text/javascript" charset="utf-8"></script>
    <script src="__STATIC_URL__/static/js/commen.js" type="text/javascript" charset="utf-8"></script>

</head>
<body>
{include file='public/header'/}
<!------------------导航-------------------------->
<section>
    {include file='public/left'/}
    <!--------------------------主要内容区域------------------------------------->
    <div class="content">

        <div class="panel mgl15 mgr15">
            <div class="panel-body">
                <!--路径导航-->
                <ol class="breadcrumb">
                    <li>
                        <a href="{:url('cardus/cardinfo',['card_id'=>$card['card_id']])}">会员卡</a>
                    </li>
                    <li class="active">积分设置</li>
                </ol>
                <div>
                    <div class="panel panel-default ng-scope">
                        <div class="panel-heading">
                            积分设置规则列表
                        </div>
                        <div class="panel-body">
                            <table class="table table-bordered">
                                <thead>
                                <tr>
                                    <td>编号</td>
                                    <td>开始时间</td>
                                    <td>结束时间</td>
                                    <td>类型</td>
                                    <td>积分倍数</td>
                                    <td>创建时间</td>
                                    <td class="text-center">操作</td>
                                </tr>
                                </thead>
                                <tbody>
                                {volist name="rulelist" id="vor"}
                                <tr ng-if="!instances.list.length" class="ng-scope">
                                    <td>{$vor.id}</td>
                                    <td>{$vor.begin_time|date="Y-m-d H:i",###}</td>
                                    <td>{$vor.end_time|date="Y-m-d H:i",###}</td>
                                    <td>
                                        {switch name="vor.type"}
                                        {case value="1"}关闭{/case}
                                        {case value="2"}多倍{/case}
                                        {default /}未知
                                        {/switch}
                                    </td>
                                    <td>{$vor.bonus_max}</td>
                                    <td>{$vor.creattime|date="Y-m-d H:i",###}</td>

                                    <td>
                                        <a class="btn-link" href="{:url('cardus/bonussta',['id'=>$vor['id'],'statu'=>$vor['statu'],'card_id'=>$card['card_id']])}">
                                            {switch name="vor.statu"}
                                            {case value="1"}关闭{/case}
                                            {case value="0"}开启{/case}
                                            {default /}未知
                                            {/switch}
                                            |</a>
                                        <a class="btn-link" href="{:url('cardus/bonusdel',['id'=>$vor['id'],'card_id'=>$card['card_id']])}">删除</a>
                                    </td>
                                </tr>
                                {/volist}
                                </tbody>
                            </table>
                        </div>
                    </div>

                    <div class="panel panel-default ng-scope">
                        <form action="" method="post" onsubmit="return check()">
                            <div class="panel-heading">
                                积分设置规则
                            </div>
                            <div class="panel-body">
                                <div class="row">
                                    <div class="col-sm-6">

                                            <div class="form-horizontal" data-label="开始时间"
                                                 data-layout="horizontal">
                                                <div class="form-group">
                                                    <label class="col-sm-2 control-label">选择时间</label>
                                                    <div class="col-sm-10">
                                                        <input type="text" name="times" class="form-control" value="" placeholder="请选择开始时间-结束时间" readonly="readonly" id="starttime">
                                                        <div class="r-message text-danger"></div>
                                                    </div>
                                                </div>
                                            </div>


                                        <div class="form-horizontal" data-layout="horizontal">
                                            <div class="form-group">
                                                <label class="col-sm-2 control-label">规则类型</label>
                                                <div class="col-sm-10">
                                                    <select name="type" id="status" class="form-control" onchange="jf(this.value)">
                                                        <option value="">请选择</option>
                                                        <option value="1">关闭积分</option>
                                                        <option value="2">多倍积分</option>
                                                    </select>
                                                </div>
                                            </div>
                                        </div>
                                        <div class="form-horizontal hidden" id="iptval">
                                            <div class="form-group">
                                                <label class="col-sm-2 control-label ng-binding">积分倍数</label>
                                                <div class="col-sm-10">
                                                    <input type="text" class="form-control" autocomplete="off"
                                                           placeholder="" name="bonus_max" >
                                                    <div class="r-message text-danger"></div>
                                                    <div class="r-desc">
                                                        填写要设置的积分倍数。
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <div class="alert alert-danger"
                                     style="margin:0;">每类规则只能同时存在一个
                                </div>
                            </div>
                            <div class="panel-footer">
                                <button class="btn btn-success" type="submit">保存</button>
                            </div>
                        </form>
                    </div>

                </div>
            </div>
        </div>
        {include file='public/footer'/}
    </div>
</section>
<script src="__STATIC_URL__/static/laydate/laydate.js"></script>
<script>

    laydate.render({
        elem: '#starttime',
        type: 'datetime',
        range:'-',

        change: function(value, date,endDate){ //监听日期被切换


        }
    });

</script>
<script>
    function jf(val){
        if(val == '2'){
            $("#iptval").removeClass("hidden");
        }else{
            $("#iptval").addClass("hidden");
        }
    }
    function check(){
        var status=$("#status").val();
        var starttime=$("#starttime").val();

       

        if(starttime==""){
            alert('请选择时间！');
            return false;
        }

        if(status==""){
            alert('请选择规则类型！');
            return false;
        }

        // 校验通过，全部都不相同
        return true;

    }

</script>

</body>

</html>
